import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:marquee/marquee.dart';
import 'package:prototype/components/v_marquee/v_marquee_controller.dart';

import '../../theme/custom_theme.dart';

class VMarquee extends StatelessWidget {
  const VMarquee({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    VMarqueeController logic = Get.put(VMarqueeController());
    final state = Get
        .find<VMarqueeController>()
        .state;
    return DecoratedBox(
      decoration: BoxDecoration(
        color: CustomTheme.colorSchema.backgroundColor
      ),
      child: Container(
        margin: EdgeInsets.symmetric(
          horizontal: 20.w,
          vertical: 10.h,
        ),
        padding: EdgeInsets.symmetric(
          horizontal: 15.w,
          vertical: 5.h,
        ),
        decoration: BoxDecoration(
          color: CustomTheme.colorSchema.tertiary,
          borderRadius: const BorderRadius.all(
            Radius.circular(5),
          ),
        ),
        height: 28.h,
        child: Row(
          children: [
            Image.asset(
              'assets/images/home/speaker.png',
              width: 20,
            ),
            SizedBox(
              width: 8.w,
            ),
            Expanded(
                child: Obx(() {
                  if (state.noticeString != '') {
                    return Marquee(
                      text: state.noticeString,
                      velocity: 100,
                    );
                  }
                  return const Text('');
                })
            )
          ],
        ),
      ),
    );
  }
}
